//
//  CELogClient.h
//  CELog_Example
//
//  Created by maoerduo on 2021/2/25.
//  Copyright © 2021 maoerduo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CECommonLog.h"
#import "CELogClientConfig.h"

NS_ASSUME_NONNULL_BEGIN

typedef NSTimeInterval (^TimeIntervalReadBlock)(void);
typedef NSString * _Nullable (^StringReadBlock)(void);


@interface CELogClient : NSObject

@property (nonatomic, readonly) CELogClientConfig * logConfig;

//用户第一次安装的时间
@property (nonatomic, copy) TimeIntervalReadBlock getFirstOpenTimeInterval;

//APP安装的渠道
@property (nonatomic, copy) StringReadBlock getChannel;

//设备的UUID
@property (nonatomic, copy) StringReadBlock getDeviceUUID;

//用户的ID, 如果用户登陆了，可以设置用户的ID
@property (nonatomic, copy) NSString * userID;


+ (instancetype)shared;

+ (instancetype)clientWithConfig:(CELogClientConfig *)config;

- (void)setupWithConfig:(CELogClientConfig *)config;

- (void)setCommonLog:(id<CECommonLog>)commonLog;

#pragma mark - 事件日志
- (void)logEvent:(NSString *)eventName;
- (void)logEvent:(NSString *)eventName log:(NSDictionary<NSString *, NSString*> * _Nullable)log;

- (void)startDurationLogEvent:(NSString *)eventName log:(NSDictionary<NSString *, NSString *> * _Nullable)log;
- (void)stopDurationLogEvent:(NSString *)eventName log:(NSDictionary<NSString *, NSString *> * _Nullable)log;
- (void)updateDurationLogEvent:(NSString *)eventName log:(NSDictionary<NSString *, NSString *> * _Nullable)log;

- (void)removeDurationLogEvent:(NSString *)eventName;


#pragma mark - 页面日志
- (void)logPage:(NSString *)pageName;
- (void)logPage:(NSString *)pageName log:(NSDictionary<NSString *, NSString *> * _Nullable)log;

- (void)startDurationPageLog:(NSString *)pageName;
- (void)pauseDurationPageLog:(NSString *)pageName;
- (void)stopDurationPageLog:(NSString *)pageName;

- (void)removeDurationPageLog:(NSString *)pageName;


@end

NS_ASSUME_NONNULL_END
